package com.gxa.controller.system;

import com.gxa.service.system.LoginService;
import com.gxa.utils.MessageCode;
import com.gxa.utils.Result;
import com.gxa.utils.ResultUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Author lch
 * @Date 2024/2/22 14:44
 * @Description
 **/
@RestController
public class LoginController {

    @Resource
    private LoginService loginService;

    /**
     * 用户登录
     *
     * @param jobNumber 员工工号
     * @param password  密码
     * @return
     */
    @PostMapping("/login")
    public Result login(String jobNumber, String password) {
        String token = loginService.login(jobNumber, password);
        if (token != null) {
            return ResultUtils.buildSuccess(token);
        }
        return ResultUtils.buildFail(MessageCode.FAIL_LOGIN);
    }
}
